/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skelbkim;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

/**
 *
 * @author laimis
 */
public class SkelbiamInfo extends SeleneseTestCase {

    public void setUp() throws Exception {
        setUp("http://skelbiam.info/", "*firefox");
    }

    public void newNotation(String noticeText, String phone, String name, String noticeTitle, String email) throws Exception {
        selenium.open("/");
        selenium.click("link=Naujas skelbimas");
        if (isPageLoude()) {
            selenium.select("f_category", "label=WWW svetainės");
            selenium.type("f_title", noticeTitle);
            selenium.type("text", noticeText);
            selenium.select("f_duration", "label=7 dienos");
            selenium.type("f_name", name);
            selenium.select("f_country", "label=Klaipėda");
            selenium.type("f_email", email);
            selenium.type("f_tel", phone);
            selenium.click("Submit");
        }
        selenium.stop();
    }

    private boolean isPageLoude() {
        boolean result = true;
        while (!selenium.isElementPresent("//div/div[2]/div[3]/form/table[4]/tbody/tr[2]/td[2]/input")) {
            selenium.waitForPageToLoad("5000");
        }
        return result;
    }
}

